﻿using System;

namespace HealthCommunity.Controls
{
	public partial class UCSiteInfo : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				BindInfo();
			}
		}

		private void BindInfo()
		{
			var u = SiteContext.Current.CurrentUser;

			if (u != null && u.Role != null && u.Role.RoleName.Equals("admin"))
			{
				siteinfo.Visible = false;
			}
			else
			{
				if (u != null && u.DrugStoreID.GetValueOrDefault(0) > 0)
				{
					var drugstoreProvider = new DBProvider.Providers.DrugStoreProvider();
					var drugstore = drugstoreProvider.GetDrugStore(u.DrugStoreID.Value);
					if (drugstore != null)
					{
						this.siteinfocontainer.InnerHtml = drugstore.DrugStoreDescription;
					}
				}
			}
		}
	}
}